package com.ny.service.impl;

import com.ny.entity.Device;
import com.ny.mapper.DeviceMapper;
import com.ny.service.DeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Optional;


@Service
public class DeviceServiceImpl implements DeviceService {

    @Autowired
    private DeviceMapper deviceMapper;

    // 查询所有设备信息
    @Override
    public List<Device> findAll() {
        return deviceMapper.findAll();
    }

    // 根据设备名称查询设备信息
    @Override
    public List<Device> findByDeviceName(String deviceName) {
        return deviceMapper.findByDeviceName(deviceName);
    }

    // 根据时间范围和状态查询设备（离线设备查询）
    @Override
    public List<Device> findOfflineByTimeRange(Date startTime, Date endTime) {
        return deviceMapper.findByStatusAndCreatedTimeBetween(0, startTime, endTime);
    }

}